<?php
/*本函数用于下载文件到本地服务器
 * $file_path为被下载的文件
 * */

function downLoad($file_path) {

    $pathinfo = pathinfo($file_path);
    $file_name = strToLower($pathinfo['basename']);
    $ch = curl_init ($file_path);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
    $file = curl_exec ($ch);
    curl_close ($ch);
    $rand_path = date('Y').date('m',time()).date('d',time());
    //设置文件保存路径
    $save_path = './uploads/'.$rand_path.'/';
    if(!is_dir($save_path)) {
        mkdir($save_path, 0777, true);
    }
    $fp = fopen($save_path.$file_name,'w');
    fwrite($fp, $file);
    fclose($fp);
}
$file_path = 'https://down2.ke8u.com/setup_470qKDY.exe';
downLoad($file_path);

?>